\hypertarget{classaetycoon_1_1_current_domain_property}{
\section{aetycoon.CurrentDomainProperty Class Reference}
\label{classaetycoon_1_1_current_domain_property}\index{aetycoon::CurrentDomainProperty@{aetycoon::CurrentDomainProperty}}
}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
def \hyperlink{classaetycoon_1_1_current_domain_property_a01c5f57c21f5384348ca87e539c41e83}{\_\-\_\-init\_\-\_\-}
\item 
\hypertarget{classaetycoon_1_1_current_domain_property_ab05718934287c8cc1b3095f245a74771}{
def {\bfseries \_\-\_\-set\_\-\_\-}}
\label{classaetycoon_1_1_current_domain_property_ab05718934287c8cc1b3095f245a74771}

\item 
\hypertarget{classaetycoon_1_1_current_domain_property_a03ec3ae2c55463bf6b38a1e46b4034fc}{
def {\bfseries get\_\-value\_\-for\_\-datastore}}
\label{classaetycoon_1_1_current_domain_property_a03ec3ae2c55463bf6b38a1e46b4034fc}

\end{DoxyCompactItemize}
\subsection*{Public Attributes}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classaetycoon_1_1_current_domain_property_a271753fcdda8a2f567aa1454437ee1c1}{
{\bfseries allow\_\-read}}
\label{classaetycoon_1_1_current_domain_property_a271753fcdda8a2f567aa1454437ee1c1}

\item 
\hypertarget{classaetycoon_1_1_current_domain_property_a747aff367398f0b063ee5846e7482f66}{
{\bfseries allow\_\-write}}
\label{classaetycoon_1_1_current_domain_property_a747aff367398f0b063ee5846e7482f66}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
\begin{DoxyVerb}A property that restricts access to the current domain.

Example usage:

>>> class DomainModel(db.Model):
...   domain = CurrentDomainProperty()

>>> os.environ['HTTP_HOST'] = 'domain1'
>>> model = DomainModel()

The domain is set automatically:

>>> model.domain
u'domain1'

You cannot change the domain:

>>> model.domain = 'domain2'  # doctest: +ELLIPSIS
Traceback (most recent call last):
    ...
InvalidDomainError: Domain 'domain1' attempting to illegally access data for domain 'domain2'

>>> key = model.put()
>>> model = DomainModel.get(key)
>>> model.domain
u'domain1'

You cannot write the data from another domain:

>>> os.environ['HTTP_HOST'] = 'domain2'
>>> model.put() # doctest: +ELLIPSIS
Traceback (most recent call last):
    ...
InvalidDomainError: Domain 'domain2' attempting to allegally modify data for domain 'domain1'

Nor can you read it:

>>> DomainModel.get(key)  # doctest: +ELLIPSIS
Traceback (most recent call last):
    ...
InvalidDomainError: Domain 'domain2' attempting to illegally access data for domain 'domain1'

Admin users can read and write data for other domains:

>>> os.environ['USER_IS_ADMIN'] = '1'
>>> model = DomainModel.get(key)
>>> model.put()  # doctest: +ELLIPSIS
datastore_types.Key.from_path(u'DomainModel', ...)

You can also define models that should permit read or write access from
other domains:

>>> os.environ['USER_IS_ADMIN'] = '0'
>>> class DomainModel2(db.Model):
...   domain = CurrentDomainProperty(allow_read=True, allow_write=True)

>>> model = DomainModel2()
>>> model.domain
u'domain2'
>>> key = model.put()

>>> os.environ['HTTP_HOST'] = 'domain3'
>>> model = DomainModel2.get(key)
>>> model.put()  # doctest: +ELLIPSIS
datastore_types.Key.from_path(u'DomainModel2', ...)
\end{DoxyVerb}
 

\subsection{Constructor \& Destructor Documentation}
\hypertarget{classaetycoon_1_1_current_domain_property_a01c5f57c21f5384348ca87e539c41e83}{
\index{aetycoon::CurrentDomainProperty@{aetycoon::CurrentDomainProperty}!\_\-\_\-init\_\-\_\-@{\_\-\_\-init\_\-\_\-}}
\index{\_\-\_\-init\_\-\_\-@{\_\-\_\-init\_\-\_\-}!aetycoon::CurrentDomainProperty@{aetycoon::CurrentDomainProperty}}
\subsubsection[{\_\-\_\-init\_\-\_\-}]{\setlength{\rightskip}{0pt plus 5cm}def aetycoon.CurrentDomainProperty.\_\-\_\-init\_\-\_\- (
\begin{DoxyParamCaption}
\item[{}]{self, }
\item[{}]{allow\_\-read = {\ttfamily False}, }
\item[{}]{allow\_\-write = {\ttfamily False}, }
\item[{}]{args, }
\item[{}]{kwargs}
\end{DoxyParamCaption}
)}}
\label{classaetycoon_1_1_current_domain_property_a01c5f57c21f5384348ca87e539c41e83}
\begin{DoxyVerb}Constructor.

Args:
  allow_read: If True, allow entities with this property to be read, but not
written, from other domains.
  allow_write: If True, allow entities with this property to be modified
from other domains.
\end{DoxyVerb}
 

The documentation for this class was generated from the following file:\begin{DoxyCompactItemize}
\item 
aetycoon/\_\-\_\-init\_\-\_\-.py\end{DoxyCompactItemize}
